	let token;
	const init = ()=> {
		return new Promise((resolve, reject) => {
			uni.getStorage({
					key: 'user_info',
					success: (res) => {
						token = res.data.token;
						if (token) {
							uni.getLocation({
								type: 'wgs84',
								success: (res) => {
									let longitude = res.longitude;
									let latitude = res.latitude;
									uni.request({
										url: 'https://mx.acktechnologies.com.cn/api/wxapp/apply/uploadLocation',
										data: {
											"token": token,
											"longitude": longitude,
											"latitude": latitude
										},
										method: 'GET',
										success: res => {
											console.log(res);
											this.getData();
										},
										fail: (res) => {
											wxLogin();
										},
									});
								},
								fail: () => {
									wxLogin();
								}
							});
						} else {
							wxLogin();
						}
					},
					fail: () => {
						this.wxLogin();
					}
				});
			
		})
		},
	wxLogin() {
		uni.login({
			provider: 'weixin',
			success: (loginRes) => {
				console.log(loginRes)
				this.code = loginRes.code;
				this.$request('/api/wxapp/index/wxLogin', {
					'code': loginRes.code
				}).then(wxLoginRes => {
					if (wxLoginRes.code === 1) {
						this.isReg = wxLoginRes.data.is_reg;
						this.session_key = wxLoginRes.data.session_key;
						this.openid = wxLoginRes.data.openid;
						uni.setStorageSync('openid', this.openid);
						if (this.isReg) {
							this.auth();
						} else {
							uni.redirectTo({
								url: '../login/auth'
							});
						}
					}
				})
			}
		});
	}
	auth() {
		let param = {
			'openid': this.openid
		}
		this.$request('/api/wxapp/index/accountLogin', param)
			.then(res => {
				let userinfo = res.data.userinfo;
				console.log(userinfo)
				uni.setStorage({
					key: 'user_info',
					data: userinfo,
					success: () => {
						console.log('success');
						this.token = userinfo.token;
						this.getData();
					}
				});
				if (res.data.usernum > 1) {
					uni.navigateTo({
						url: '../login/user_select'
					});
				}
			})
	}
